Remove paramiko hacks - #464
Open
uruun wants to merge 2 commits into
Open
Conversation
Author
There was a problem hiding this comment.
Pull request overview
This PR removes legacy Paramiko monkeypatches from client.py (banner timeout override and SFTP %-escaping workaround) in favor of using Paramiko’s official APIs, and drops a remaining Python 2 compatibility import.
Changes:
- Removed Paramiko Transport/SFTPClient monkeypatch “hacks” and replaced banner handling with
SSHClient.connect(..., banner_timeout=...). - Introduced a module-level
BANNER_TIMEOUT = 45used across connection paths. - Removed
from __future__ import print_functionfromlibrary.py.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/SSHLibrary/library.py |
Removes the Python 2-era print_function future import. |
src/SSHLibrary/client.py |
Removes Paramiko monkeypatches and applies banner_timeout through SSHClient.connect. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
878
to
+882
| self.client.connect(self.config.host, self.config.port, username, | ||
| password, look_for_keys=look_for_keys, | ||
| allow_agent=allow_agent, | ||
| timeout=float(self.config.timeout), sock=sock_tunnel) | ||
| timeout=float(self.config.timeout), sock=sock_tunnel, | ||
| banner_timeout=BANNER_TIMEOUT) |
Comment on lines
890
to
+894
| self.client.connect(self.config.host, self.config.port, username, | ||
| password, look_for_keys=look_for_keys, | ||
| allow_agent=allow_agent, | ||
| timeout=float(self.config.timeout), sock=sock_tunnel) | ||
| timeout=float(self.config.timeout), sock=sock_tunnel, | ||
| banner_timeout=BANNER_TIMEOUT) |
Comment on lines
936
to
+941
| self.client.connect(self.config.host, self.config.port, username, | ||
| password, key_filename=key_file, | ||
| allow_agent=allow_agent, | ||
| look_for_keys=look_for_keys, | ||
| timeout=float(self.config.timeout), | ||
| sock=sock_tunnel) | ||
| sock=sock_tunnel, banner_timeout=BANNER_TIMEOUT) |
| client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | ||
| try: | ||
| client.connect(str(host), int(port), username="bad-username") | ||
| client.connect(str(host), int(port), username="bad-username", banner_timeout=BANNER_TIMEOUT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove two paramiko hacks done in
client.py. They both seem like very old workarounds and their functionality can be achieved through official paramiko APIs.The first one set the banner timeout for paramiko
Transportto 45 seconds.banner_timeoutcan be set in paramikoSSHClient.connector withTransport.banner_timeout, I went withconnectas it seems to be the expected way to do it. This might be a breaking change if someone is using the SSHLibrarySSHClient.clientdirectly as then the timeout will be the default 15 seconds.The second one is a workaround for
%symbols in file paths reported in 2012: http://code.google.com/p/robotframework-sshlibrary/issues/detail?id=55 . It seems this has been fixed in paramiko in 2014 here: paramiko/paramiko@6e9abc3 . As it has been fixed for so long I hope everyone moved on to newer paramiko and this is not needed anymore.Also removed small remaining Python 2 compatibility.